package com.zr.myorder.service.impl;

import com.zr.myorder.mapper.MyOrderMapper;
import com.zr.myorder.pojo.PaymentInformationUpdateVo;
import com.zr.myorder.service.MyOrderService;
import com.zr.paymentInformation.pojo.PaymentInformation;
import com.zr.util.ResultBuildVo;
import com.zr.util.ResultVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;


/**
 * Created by Administrator on 2019/7/3 0003.
 */
@Service
public class MyOrderServiceImpl implements MyOrderService{
        @Autowired
        private MyOrderMapper myOrderMapper;

    public ResultVo updatePaymentInformation(PaymentInformationUpdateVo paymentInformationUpdateVo ,HttpServletRequest request) {
        Integer loginId = (Integer) request.getSession().getAttribute("loginId");
        if(loginId == null){
                return ResultBuildVo.error("请登录","500");
        }
        //给数据库中的创建时间和修改时间等信息赋值
        PaymentInformation paymentInformation = new PaymentInformation();
        Date nowDate = new Date();
        paymentInformation.setUpdateTime(nowDate);
        paymentInformation.setUpdateName("张三");
        //把左边对象的数据赋值给右边对象的数据
        //注意必须相同参数名称和相同参数类型才能自动进行赋值
        BeanUtils.copyProperties(paymentInformationUpdateVo, paymentInformation);
        myOrderMapper.updatePaymentInformation(paymentInformation);
        return ResultBuildVo.success(paymentInformationUpdateVo);
    }

}
